package com.xh.bgc.services.bug;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xh.bgc.dao.BugInfoMapper;

import com.xh.bgc.pojo.BugInfo;

@Service
public class BugInfoServicesImpl implements BugInfoServices {
	private Logger lo = Logger.getLogger(BugInfoServicesImpl.class);
	@Autowired
	private BugInfoMapper mapper;

	@Override
	public void addBugInfo(BugInfo bug) {
		int i = mapper.addBugInfo(bug);
		if (i > 0) {
			lo.debug("添加信息成功");
		}

	}

	@Override
	public List<Map<String, Object>> searchSomething(String description) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("description", description);
		List<Map<String, Object>> list = mapper.searchSomething(map);
		return list;
	}

	@Override
	public List<Map<String, Object>> findByName(String description) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("description", description);
		List<Map<String, Object>> list = mapper.findByName(map);
		return list;
	}

	@Override
	public List<Map<String, Object>> buttonSearch(String description,int indexPage,int pageSize) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("description", description);
		map.put("indexPage", (indexPage-1)*pageSize);
		map.put("pageSize", pageSize);
		List<Map<String, Object>> list = mapper.buttonSearch(map);
		return list;
	}
//信息总条数
	@Override
	public int findAllPage(String description) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("description", description);
		int i =mapper.findAllPage(map);
		
		return i;
	}
//精确查询
	@Override
	public Map<String, Object> searchById(int bugid) {
/*		Map<String,Object> map =new HashMap<String, Object>();
		map.put("description", description);*/
		Map<String,Object> searchById =mapper.searchById(bugid);
		return searchById;
	}

	@Override
	public int insertBugInfo(int userid, int bugid,int satus) {
		Map<String,Object> map =new HashMap<String, Object>();
		map.put("userid", userid);
		map.put("bugid", bugid);
		map.put("satus", satus);
		if(userid!=0){
			int i =mapper.insertBugInfo(map);	
		}
		
		
		return 0;
	}
//更新查询次数 
	@Override
	public int updateNumber(int queriesNumber,int bugid) {
		Map<String,Object> map =new HashMap<String, Object>();
		map.put("queriesNumber", queriesNumber);
		map.put("bugid", bugid);
		return mapper.updateNumber(map);
	}
}
